package com.jarveis.frame.jdbc.handler;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;

import com.jarveis.frame.jdbc.ResultSetHandler;

/**
 * 数组对象结果集
 * 
 * @author liuguojun
 */
public class ArrayListHandler implements ResultSetHandler {

	@Override
	public Object handle(ResultSet rs) throws SQLException {
		ArrayList<Object[]> result = new ArrayList<Object[]>();
		
		ResultSetMetaData meta = rs.getMetaData();
		int cols = meta.getColumnCount();
		while (rs.next()) {
			Object[] object = new Object[cols];
			for (int i = 0; i < cols; i++) {
				object[i] = rs.getObject(i + 1);
			}
			result.add(object);
		}

		return result;
	}

}
